<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');

class Search extends MY_Controller {

	function __construct()
	{
		parent::__construct();
		
		
	}

	function index()
	{
		$this->ShowHeader();
		$this->ShowFooter();
	}
    
    function criteria()
    {
        $criteria = $_POST['search_text'];
        if($criteria)
        {
            redirect('search/results/'.urlencode($criteria));
        }
        else
        {
            redirect('search');
        }
            
        
    }
    
    function results()
    {
        $criteria = urldecode($this->uri->segment(3));
        
        $data['query'] = search_articles_for_target('', '', $criteria , 20);
        
		$data['target_name'] = 'Search results for: "' . $criteria . '"';
		
        $b = array ();
        $b[] = $this->UserFeed();
        $b[] = $this->BoxRecent(array($data['target_name']));
        $b[] = $this->BoxFeatured();
		
        $data2['boxes'] = $b;

	
		$this->ShowHeader();
		$this->load->view('main_page', $data);
		$this->load->view('box_frame', $data2);
		$this->ShowFooter();
    }
}

/* End of file welcome.php */
/* Location: ./application/controllers/welcome.php */